home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / MATH / VLN_20 / GETSET.INC < prev    next >
Text File  |  1995-03-30  |  4KB  |  171 lines

  1.  
  2. {)))))))))))))))))))))))))))))))))}
  3.   function GetCount( regNo  : integer ) : integer;
  4. {)))))))))))))))))))))))))))))))))}
  5.   begin
  6.      GetCount := vlnVars[regNo]^.count;
  7.   end;
  8.  
  9. {)))))))))))))))))))))))))))))))))}
  10.   function GetBinSize ( Reg1 : integer )  : integer;
  11. {)))))))))))))))))))))))))))))))))}
  12.   var
  13.     c,  a : integer;
  14.     n : word;
  15.   begin
  16.      c := GetCount( Reg1 );
  17.      a := (c-1) * 16;
  18.      n := vlnVars[Reg1]^.tvln[c] ;
  19.      while (n>0) do
  20.         begin
  21.           n := n shr 1;
  22.           inc(a);
  23.         end;
  24.      GetBinSize := a;
  25.  
  26.   end;
  27.  
  28.  
  29. {)))))))))))))))))))))))))))))))))}
  30.   function GetSign( regNo  : integer ) : integer;
  31. {)))))))))))))))))))))))))))))))))}
  32.   begin
  33.      GetSign := vlnVars[regNo]^.sign;
  34.   end;
  35.  
  36. {(((((((((((((((((((((((((((((}
  37.   function FlipSign( regNo  : integer ) : integer;
  38.       begin
  39.        vlnVars[ RegNo]^.Sign := - vlnVars[ RegNo]^.Sign;
  40.        FlipSign :=  vlnVars[ RegNo]^.Count;
  41.       end;
  42.  
  43.  
  44. {))))))))))))))))))))))))))))))))))))}
  45. {}  procedure tVryLrgNo.SetRandom   {} (binCnt  : integer);
  46. {))))))))))))))))))))))))))))))))))))}
  47. var
  48.    bitsRemain, i     : integer;
  49. begin
  50.    Randomize;
  51.    bitsRemain := binCnt mod 16 ;   {0 to 15}
  52.    Count :=  (binCnt) div 16 ;   {16 bits per word }
  53.    if max<count then
  54.       begin
  55.        callError('Random too big error');
  56.        exit;
  57.       end;
  58.    sign := 1; {positive}
  59.    for i := Count+1 downto 1 do
  60.       tVLN[i] := random(32768) shl 1 + random(2);
  61.  
  62.    if bitsRemain>0 then      { value is 0 to 15}
  63.      begin
  64.        inc(Count);
  65.        for i := 15 downto bitsRemain do   {reduce MS Byte}
  66.           tVLN[Count] := tVLN[Count] shr 1;
  67.      end;
  68.    if tVLN[Count]=0 then dec(count);
  69. end;
  70.  
  71.  
  72. {))))))))))))))))))))))))))))))}
  73. {} procedure tVryLrgNo.SetVal {}  ( cnt, sgn : integer;
  74. {))))))))))))))))))))))))))))))}   pnew     : pWordArray);
  75. var
  76.     i : integer;
  77. Begin
  78.    if cnt >0 then
  79.      for i := 1 to cnt do
  80.        tVLN[i] := pnew^[i] ;
  81.    count := cnt;
  82.    sign := sgn;
  83. end;
  84.  
  85.  
  86.  
  87. {)))))))))))))))))))))))))))))))))}
  88. {}   procedure tVryLrgNo.Clear   {}  ( n : integer);
  89. {)))))))))))))))))))))))))))))))))}
  90. var i : integer;
  91. begin
  92.    if max<n then
  93.       begin
  94.        callError('Clear too big error');
  95.        exit;
  96.       end;
  97.    count := 0;
  98.    sign := 1;
  99.    for i := 1 to n do
  100.       tvln[i] := 0;
  101.  
  102. end;
  103.  
  104.  
  105.  
  106. {(((((((((((((((((((((((((((((())((}
  107. {}  procedure tVryLrgNo.__SetWord  {}  ( n : integer; nval : word );
  108. {((((((((((((((((((((((((((((((((((}
  109.  var i : integer;
  110.  begin
  111.    if n > count
  112.       then
  113.         begin
  114.            if n> wksize then exit;
  115.            for i := count+1 to n-1 do
  116.              tVln[i] :=  0;
  117.            count := n;
  118.         end;
  119.    tVln[n] := nval;
  120.  
  121.  end;
  122.  
  123. {(((((((((((((((((((((((((((((())((}
  124. {}  function tVryLrgNo.__GetWord  {}  ( n : integer) : word ;
  125. {((((((((((((((((((((((((((((((((((}
  126.  begin
  127.    if n > count
  128.       then __GetWord := (0)
  129.       else __GetWord := tVln[n];
  130.  end;
  131.  
  132.    function  SetWord( Reg1, pos: integer; nval : word ) : integer;
  133.        begin
  134.          vlnVars[ Reg1]^.__SetWord(pos,nval);
  135.          SetWord :=  vlnVars[ Reg1]^.count;
  136.        end;
  137.  
  138.     function  GetWord( Reg1, n : integer) :  word ;
  139.         begin
  140.             GetWord := vlnVars[ Reg1]^.__GetWord(n);
  141.         end;
  142.  
  143.  
  144. {(((((((((((((((((((((((((((((())((}
  145. {}  procedure tVryLrgNo.SetSmall  {} (n:integer );
  146. {((((((((((((((((((((((((((((((((((}
  147. begin
  148.    count := 1;
  149.    sign := 1;
  150.    if n<0 then begin
  151.      sign := -1;
  152.      n:= -n;
  153.      end;
  154.    tvln[1] := n;
  155. end;
  156.  
  157.  
  158. {(((((((((((((((((((((((((((((((((}
  159. procedure SetWkSize ( n:integer);
  160. begin
  161.    wksize := n;
  162. end;
  163.  
  164. {(((((((((((((((((((((((((((((((((}
  165. function GetWkSize : integer;
  166. begin
  167.    GetWkSize := wksize;
  168. end;
  169.  
  170.  
  171. {(((((((((((((((((((((((((((((((((}